<template>
	<view>
		<view-grid ref="grid" :index="true" :options="options">
			<!-- 自定义slot -->
			<view @click="viewClick" slot="gridHeader" class="grid-header">
				{{gridHeaderText}}
			</view>
		</view-grid>
	</view>
</template>

<script>
	//************************************************
	//  *Author：jxx
	//  *QQ：283591387
	//  *自定义业务逻辑扩展
	//************************************************
    import extend from './q_client_visitExtend.js'
    import options from './q_client_visitOptions.js';
	export default {
		data() {
			let _options = options();
	        _options.extend = extend;
			return {
				gridHeaderText: "",//随便输入字符后可以显示出来
				options: _options
			}
		},
		onShow() {
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2];
			this.time = setInterval(() => {
				console.log('定时器');
				if (this.$refs.grid) {
					clearInterval(this.time);
					if (this.$refs.grid.fabButtons) {
						this.$refs.grid.fabButtons.forEach((item) => {
							if (item.name == '添加') {
								item.onClick = () => {
									const optionsObj = {
										// editFormFields: this.options.editFormFields,
										editFormOptions: this.options.editFormOptions,
										// detailColumns: this.options.detailOptions.columns,
										// detailtable: this.options.table
									};
									uni.setStorageSync('optionsObj', JSON.stringify(optionsObj));
									uni.navigateTo({
										url: '/pages/addPage/addPage?biaoming=q_client_visit&currentAction=Add&ID=Client_visit&zibiaoming=""&mapShow=true&detailTableShow=false'
									});
								};
							}
						});
					}
					if (prevPage.route == 'pages/addPage/addPage') {
						this.$refs.grid.searchFormFields.AuditStatus = '1';
						this.$refs.grid.searchFormOptions.forEach((item) => {
							if (item.field == 'AuditStatus') {
								item.disabled = true;
							}
						});
					}
					this.$refs.grid.refresh();
				}
			}, 500);
		},
		methods: {
			viewClick() {
				//获取生成页面grid的对象
				console.log(this.$refs.grid.searchFormFields)
			}
		}
	}
</script>

<style>
</style>
